package cn.micai.base.lambda;

import java.util.Arrays;
import java.util.List;

/**
 * 描述：Java – Check if Array contains a certain value?
 * <p>
 *     检查数组是否包含某个值
 *
 * @author: 赵新国
 * @date: 2018/6/22 19:55
 */
public class StringArrayExample1 {

    public static void main(String [] args) {

        // 1. String Arrays
        String [] alphabet = new String [] {"A", "B", "C", "D"};

        // Convert String Array to List
        /*List<String> list = Arrays.asList(alphabet);
        if (list.contains("A")) {
            System.out.println("Hello A");
        }

        // A or B
        if (list.contains("A") || list.containsAll(Arrays.asList("A","B"))) {
            System.out.println("Hello A or B");
        }

        // A and B
        if (list.containsAll(Arrays.asList("A","B"))) {
            System.out.println("Hello A and B");
        }

        // A and C
        if (list.containsAll(Arrays.asList("A","C"))) {
            System.out.println("Hello A and C");
        }*/


        // In Java 8, you can do this :

        // Convert to stream and test it
        /*boolean result = Arrays.stream(alphabet).anyMatch("A"::equals);
        if (result) {
            System.out.println("Hello A");
        }*/

    }
}
